﻿<UserControl x:Class="Samba.Presentation.Terminal.TicketScreenView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:FlexButton="clr-namespace:FlexButton;assembly=FlexButton" xmlns:Common="clr-namespace:Samba.Presentation.Common;assembly=Samba.Presentation.Common" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <ScrollViewer Common:KineticBehaviour.HandleKineticScrolling="True" VerticalScrollBarVisibility="Auto">
            <ItemsControl ItemsSource="{Binding OpenTickets}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel>

                        </WrapPanel>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button 
                        Focusable="False"
                        Command="{Binding DataContext.SelectTicketCommand,RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}"
                        CommandParameter ="{Binding}"
                        MaxHeight="25">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Border Margin="1" BorderThickness="1" Background="{Binding ButtonColor}" BorderBrush="Silver">
                                        <Viewbox>
                                            <TextBlock VerticalAlignment="Center"  Margin="2,0" 
                                                   FontWeight="Bold" Text="{Binding Title}" 
                                                   TextAlignment="Center"/>
                                        </Viewbox>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="Button.IsPressed" Value="True">
                                            <Setter Property="Foreground" Value="Red"/>
                                        </Trigger>

                                        <Trigger Property="Button.IsPressed" Value="False">
                                            <Setter Property="Foreground" Value="{Binding TitleTextColor}"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        <FlexButton:FlexButton Margin="0,1,0,0" Command="{Binding CreateNewTicketCommand}" Content="{Binding CreateNewTicketCommand.Caption}" Grid.Row="1" HorizontalAlignment="Stretch" Height="30"></FlexButton:FlexButton>
    </Grid>
</UserControl>
